<template>
	<view class="u-page">
		  <input type="text" v-model="dictExpressVal" placeholder="搜索快递公司" class="search-input">
		  <view>
			  <view v-for="item in filterList" :key="item.engname">
				<view class="cell-wrap" @click="selDictExpress(item)">
					{{item.name}}
				</view>
			  </view>
		  </view>
	</view>
</template>

<script>
	import api from "@/api/api.js"
	export default {
		data() {
			return {
				index:null,
				dictExpress:[],
				dictExpressVal:""
			}
		},
		async onLoad(options) {
			await this.$onLaunched;	
			this.getDictExpress();
		},
		computed:{
			filterList(){
				let result = this.dictExpress;
				if(this.dictExpressVal!=""){
					result = this.dictExpress.filter(val=>{
						return (val.name.indexOf(this.dictExpressVal)!=-1)
					})
				}
				return result
			}
		},
		methods: {
			selDictExpress(obj){
				uni.$emit('updateData', obj)
				uni.navigateBack({
					delta: 1
				})
			},
			async getDictExpress(){
				const result = await api.dictExpress({});
				this.dictExpress = result.data
			},
		}
	}
</script>

<style lang="scss" scoped>
	.search-input{
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		position: sticky;
		top:0;
		z-index: 9999;
		box-sizing: border-box;
		font-size: 30rpx;
		padding: 5rpx 10rpx;
		background: #fff;		
	}
	.cell-wrap{
		padding: 30rpx 30rpx;
		border-bottom: 1rpx #d6d7d9 solid;
		font-size: 30rpx;
	}
</style>
